package com.hoshiibuy.sys.permission.feign.fallback;

import java.util.LinkedList;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.hoshiibuy.sys.permission.feign.IdGeneratorRemote;

/**
 * 
 * @Description: 测试熔断,调用本地方法,正式环境请勿使用
 * @author Mr.wu
 * @date: 2019年4月23日 下午4:15:15
 */
@Component
public class IdGeneratorTestFallback implements IdGeneratorRemote {

	private final static Logger logger = LoggerFactory.getLogger(IdGeneratorTestFallback.class);

	@Override
	public String getId() {
		logger.warn("id服务触发fallback,使用本地雪花算法");
		return IdWorker.getIdStr();
	}

	@Override
	public LinkedList<String> getIdList(int count) {
		logger.warn("id服务触发fallback,使用本地雪花算法");
		LinkedList<String> idList = new LinkedList<String>();
		for (int i = 0; i < count; i++) {
			idList.push(IdWorker.getIdStr());
		}
		return null;
	}
}
